package ar.com.mooral.activities;

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Vector;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import ar.com.mooral.crohn.application.CrohnContext;
import ar.com.mooral.data.Depositions;
import ar.com.mooral.data.FoodList;
import ar.com.mooral.data.SexualActivityIncidence;
import ar.com.mooral.pojo.MedicationPojo;


public class MedicationAddFrequency extends CrohnActivity {
	
	private MedicationPojo pojo;
	
	protected void onStart() {
		super.onStart();

		if(CrohnContext.isPojoLoaded())
 		{
			
			((TextView)findViewById(R.id.txtMedicationAddFrequencyQuantity)).setText(pojo.getFrequencyQuantity()!=null ? pojo.getFrequencyQuantity() : "");
			((TextView)findViewById(R.id.txtMedicationAddFrequencyEach)).setText(pojo.getFrequencyEach()!=null ? pojo.getFrequencyEach() : "");
			((TextView)findViewById(R.id.txtMedicationAddFrequencyTime)).setText(pojo.getFrequencyTime()!=null ? pojo.getFrequencyTime() : "");
		}
		
	}
	

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.medication_add_frequency);
        
		pojo = (MedicationPojo)CrohnContext.getPojo();
		
		// SAVE
        TextView lblMedicationAddFrequencySave = (TextView) findViewById(R.id.lblMedicationAddFrequencySave);
        lblMedicationAddFrequencySave.setOnClickListener (new View.OnClickListener() {
		    public void onClick(View view) {
		    	/*
		    	CrohnContext.setMedicationFrequencyQuantity( Integer.parseInt(((TextView)findViewById(R.id.txtMedicationAddFrequencyQuantity)).getText().toString()));
		    	CrohnContext.setMedicationFrequencyEach( Integer.parseInt(((TextView)findViewById(R.id.txtMedicationAddFrequencyEach)).getText().toString()));
		    	CrohnContext.setMedicationFrequencyTime( ((TextView)findViewById(R.id.txtMedicationAddFrequencyTime)).getText().toString());
		    	CrohnContext.setMedicationFrequencyLoaded(true);
				*/
		    	
		    	pojo.setFrequencyQuantity( ((TextView)findViewById(R.id.txtMedicationAddFrequencyQuantity)).getText().toString());
		    	pojo.setFrequencyEach( ((TextView)findViewById(R.id.txtMedicationAddFrequencyEach)).getText().toString());
		    	pojo.setFrequencyTime( ((TextView)findViewById(R.id.txtMedicationAddFrequencyTime)).getText().toString());

		    	finish();
		    }
		});		

        // CANCEL
        TextView lblMedicationAddFrequencyCancel = (TextView) findViewById(R.id.lblMedicationAddFrequencyCancel);
        lblMedicationAddFrequencyCancel.setOnClickListener (new View.OnClickListener() {
		    public void onClick(View view) {
		    	finish();
		    }
		});	
        
    }
}
